package com.lsa.letcode.the27.removeEl;

import org.junit.Assert;
import org.junit.Test;

public class RemoveElTest {
	@Test
	public void test() {
		Solution s = new Solution();
		
		test(s, new int[]{1,2,3,4,5}, 4, new int[]{1,2,3,5});
		test(s, new int[]{1,2,3,4,5}, 4, new int[]{1,2,3,5});
		test(s, new int[]{1,1,2,3,4}, 1, new int[]{2,3,4});
		test(s, new int[]{5,2,3,4,5,5,5}, 5, new int[]{2,3,4});
		test(s, new int[]{1,1,1,1}, 1, new int[]{});
		test(s, new int[]{}, 1, new int[]{});
	}

	private void test(Solution s, int[] input, int e, int[] expected) {
		int len = s.removeElement(input, e);
		int[] actual = new int[len];
		System.arraycopy(input, 0, actual, 0, len);
		Assert.assertArrayEquals(expected, actual);
	}
}